package org.hl7.fhir.r5.test.profiles.codegen;

import java.util.List;
import java.util.ArrayList;
import javax.annotation.Nullable;
import java.util.Date;


import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.r5.profilemodel.PEBuilder;
import org.hl7.fhir.r5.profilemodel.PEInstance;
import org.hl7.fhir.r5.profilemodel.PEBuilder.PEElementPropertiesPolicy;
import org.hl7.fhir.r5.profilemodel.gen.PEGeneratedBase;
import org.hl7.fhir.r5.profilemodel.gen.Min;
import org.hl7.fhir.r5.profilemodel.gen.Max;
import org.hl7.fhir.r5.profilemodel.gen.Label;
import org.hl7.fhir.r5.profilemodel.gen.Doco;
import org.hl7.fhir.r5.profilemodel.gen.BindingStrength;
import org.hl7.fhir.r5.profilemodel.gen.ValueSet;
import org.hl7.fhir.r5.profilemodel.gen.MustSupport;
import org.hl7.fhir.r5.profilemodel.gen.Definition;


// Generated by the HAPI Java Profile Generator, 5/11/24, 6:00 pm

/**
 * The detailed description of a substance, typically at a level beyond what is 
 * used for prescribing.
 *
 */
public class SubstanceDefinitionUvEpi extends PEGeneratedBase {

  public static final String CANONICAL_URL = "http://hl7.org/fhir/uv/emedicinal-product-info/StructureDefinition/SubstanceDefinition-uv-epi|1.0.0";

  @Min("0") @Max("1") @Doco("")
  private String id;  // 

  @Min("0") @Max("*") @Doco("Additional content defined by implementations")
  @Definition("May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.")
  private List<Extension> extensions = new ArrayList<>();  // Additional content defined by implementations

  @Min("0") @Max("*") @Doco("Extensions that cannot be ignored")
  @Definition("May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).")
  private List<Extension> modifierExtensions = new ArrayList<>();  // Extensions that cannot be ignored

  @Min("1") @Max("*") @Doco("Identifier by which this substance is known")
  @Definition("Identifier by which this substance is known.")
  private List<Identifier> identifiers = new ArrayList<>();// @NotNull  // Identifier by which this substance is known

  @Min("0") @Max("*") @Doco("Supporting literature")
  @Definition("Supporting literature.")
  private List<Reference> informationSources = new ArrayList<>();  // Supporting literature

  @Min("0") @Max("*") @Doco("Textual comment about the substance's catalogue or registry record")
  @Definition("Textual comment about the substance's catalogue or registry record.")
  private List<Annotation> notes = new ArrayList<>();  // Textual comment about the substance's catalogue or registry record

  @Min("0") @Max("*") @Doco("The entity that creates, makes, produces or fabricates the substance")
  @Definition("The entity that creates, makes, produces or fabricates the substance. This is a set of potential manufacturers but is not necessarily comprehensive.")
  private List<Reference> manufacturers = new ArrayList<>();  // The entity that creates, makes, produces or fabricates the substance

  @Min("0") @Max("*") @Doco("An entity that is the source for the substance. It may be different from the manufacturer")
  @Definition("An entity that is the source for the substance. It may be different from the manufacturer. Supplier is synonymous to a distributor.")
  private List<Reference> suppliers = new ArrayList<>();  // An entity that is the source for the substance. It may be different from the manufacturer

  @Min("0") @Max("*") @Doco("Moiety, for structural modifications")
  @Definition("Moiety, for structural modifications.")
  private List<BackboneElement> moieties = new ArrayList<>();  // Moiety, for structural modifications

  @Min("0") @Max("*") @Doco("General specifications for this substance")
  @Definition("General specifications for this substance.")
  private List<BackboneElement> characterizations = new ArrayList<>();  // General specifications for this substance

  @Min("0") @Max("*") @Doco("General specifications for this substance")
  @Definition("General specifications for this substance.")
  private List<BackboneElement> properties = new ArrayList<>();  // General specifications for this substance

  @Min("0") @Max("1") @Doco("General information detailing this substance")
  @Definition("General information detailing this substance.")
  private Reference referenceInformation;  // General information detailing this substance

  @Min("0") @Max("*") @Doco("The average mass of a molecule of a compound")
  @Definition("The average mass of a molecule of a compound compared to 1/12 the mass of carbon 12 and calculated as the sum of the atomic weights of the constituent atoms.")
  private List<BackboneElement> molecularWeights = new ArrayList<>();  // The average mass of a molecule of a compound

  @Min("0") @Max("1") @Doco("Structural information")
  @Definition("Structural information.")
  private BackboneElement structure;  // Structural information

  @Min("0") @Max("*") @Doco("Codes associated with the substance.")
  @Definition("Codes associated with the substance.")
  private List<BackboneElement> codes = new ArrayList<>();  // Codes associated with the substance.

  @Min("0") @Max("*") @Doco("International Non-Proprietary Name (INN) of the substance; or United States Adopted Name (USAN) if applicable.")
  @Definition("Names applicable to this substance.")
  private List<BackboneElement> names = new ArrayList<>();  // International Non-Proprietary Name (INN) of the substance; or United States Adopted Name (USAN) if applicable.

  @Min("0") @Max("*") @Doco("A link between this substance and another")
  @Definition("A link between this substance and another, with details of the relationship.")
  private List<BackboneElement> relationships = new ArrayList<>();  // A link between this substance and another

  @Min("0") @Max("1") @Doco("Data items specific to nucleic acids")
  @Definition("Data items specific to nucleic acids.")
  private Reference nucleicAcid;  // Data items specific to nucleic acids

  @Min("0") @Max("1") @Doco("Data items specific to polymers")
  @Definition("Data items specific to polymers.")
  private Reference polymer;  // Data items specific to polymers

  @Min("0") @Max("1") @Doco("Data items specific to proteins")
  @Definition("Data items specific to proteins.")
  private Reference protein;  // Data items specific to proteins

  @Min("0") @Max("1") @Doco("Material or taxonomic/anatomical source")
  @Definition("Material or taxonomic/anatomical source for the substance.")
  private BackboneElement sourceMaterial;  // Material or taxonomic/anatomical source


  /**
   * Parameter-less constructor.
   *
   */
  public SubstanceDefinitionUvEpi() {
  }

  /**
   * Construct an instance of the object, and fill out all the fixed values 
   *
   */
  public SubstanceDefinitionUvEpi(IWorkerContext context) {
    workerContext = context;
    PEBuilder builder = new PEBuilder(context, PEElementPropertiesPolicy.EXTENSION, true);
    PEInstance src = builder.buildPEInstance(CANONICAL_URL, builder.createResource(CANONICAL_URL, false));
    load(src);
  }

  /**
   * Populate an instance of the object based on this source object 
   *
   */
  public static SubstanceDefinitionUvEpi fromSource(IWorkerContext context, SubstanceDefinition source) {
    SubstanceDefinitionUvEpi theThing = new SubstanceDefinitionUvEpi();
    theThing.workerContext = context;
    PEBuilder builder = new PEBuilder(context, PEElementPropertiesPolicy.EXTENSION, true);
    PEInstance src = builder.buildPEInstance(CANONICAL_URL, source);
    theThing.load(src);
    return theThing;
  }


  public void load(PEInstance src) {
    clear();
    if (src.hasChild("id")) {
      id = ((IdType) src.child("id").asDataType()).getValue();
    }
    for (PEInstance item : src.children("extension")) {
      extensions.add((Extension) item.asDataType());
    }
    for (PEInstance item : src.children("modifierExtension")) {
      modifierExtensions.add((Extension) item.asDataType());
    }
    for (PEInstance item : src.children("identifier")) {
      identifiers.add((Identifier) item.asDataType());
    }
    for (PEInstance item : src.children("informationSource")) {
      informationSources.add((Reference) item.asDataType());
    }
    for (PEInstance item : src.children("note")) {
      notes.add((Annotation) item.asDataType());
    }
    for (PEInstance item : src.children("manufacturer")) {
      manufacturers.add((Reference) item.asDataType());
    }
    for (PEInstance item : src.children("supplier")) {
      suppliers.add((Reference) item.asDataType());
    }
    for (PEInstance item : src.children("moiety")) {
      moieties.add((BackboneElement) item.asElement());
    }
    for (PEInstance item : src.children("characterization")) {
      characterizations.add((BackboneElement) item.asElement());
    }
    for (PEInstance item : src.children("property")) {
      properties.add((BackboneElement) item.asElement());
    }
    if (src.hasChild("referenceInformation")) {
      referenceInformation = (Reference) src.child("referenceInformation").asDataType();
    }
    for (PEInstance item : src.children("molecularWeight")) {
      molecularWeights.add((BackboneElement) item.asElement());
    }
    if (src.hasChild("structure")) {
      structure = (BackboneElement) src.child("structure").asElement();
    }
    for (PEInstance item : src.children("code")) {
      codes.add((BackboneElement) item.asElement());
    }
    for (PEInstance item : src.children("name")) {
      names.add((BackboneElement) item.asElement());
    }
    for (PEInstance item : src.children("relationship")) {
      relationships.add((BackboneElement) item.asElement());
    }
    if (src.hasChild("nucleicAcid")) {
      nucleicAcid = (Reference) src.child("nucleicAcid").asDataType();
    }
    if (src.hasChild("polymer")) {
      polymer = (Reference) src.child("polymer").asDataType();
    }
    if (src.hasChild("protein")) {
      protein = (Reference) src.child("protein").asDataType();
    }
    if (src.hasChild("sourceMaterial")) {
      sourceMaterial = (BackboneElement) src.child("sourceMaterial").asElement();
    }

  }

  /**
   * Build a instance of the underlying object based on this wrapping object 
   *
   */
  public SubstanceDefinition build(IWorkerContext context) {
    workerContext = context;
    return build();
  }

  /**
   * Build a instance of the underlying object based on this wrapping object 
   *
   */
  public SubstanceDefinition build() {
    SubstanceDefinition theThing = new SubstanceDefinition();
    PEBuilder builder = new PEBuilder(workerContext, PEElementPropertiesPolicy.EXTENSION, true);
    PEInstance tgt = builder.buildPEInstance(CANONICAL_URL, theThing);
    save(tgt, false);
    return theThing;
  }

  /**
   * Save this profile class into an existing resource (overwriting anything that 
   * exists in the profile) 
   *
   */
  public void save(IWorkerContext context, SubstanceDefinition dest, boolean nulls) {
    workerContext = context;
    PEBuilder builder = new PEBuilder(context, PEElementPropertiesPolicy.EXTENSION, true);
    PEInstance tgt = builder.buildPEInstance(CANONICAL_URL, dest);
    save(tgt, nulls);
  }

  public void save(PEInstance tgt, boolean nulls) {
    tgt.clear("id");
    if (id != null) {
      tgt.makeChild("id").data().setProperty("value", new IdType(id));
    }
    tgt.clear("extension");
    for (Extension item : extensions) {
      tgt.addChild("extension", item);
    }
    tgt.clear("modifierExtension");
    for (Extension item : modifierExtensions) {
      tgt.addChild("modifierExtension", item);
    }
    tgt.clear("identifier");
    for (Identifier item : identifiers) {
      tgt.addChild("identifier", item);
    }
    tgt.clear("informationSource");
    for (Reference item : informationSources) {
      tgt.addChild("informationSource", item);
    }
    tgt.clear("note");
    for (Annotation item : notes) {
      tgt.addChild("note", item);
    }
    tgt.clear("manufacturer");
    for (Reference item : manufacturers) {
      tgt.addChild("manufacturer", item);
    }
    tgt.clear("supplier");
    for (Reference item : suppliers) {
      tgt.addChild("supplier", item);
    }
    tgt.clear("moiety");
    for (BackboneElement item : moieties) {
      tgt.addChild("moiety", item);
    }
    tgt.clear("characterization");
    for (BackboneElement item : characterizations) {
      tgt.addChild("characterization", item);
    }
    tgt.clear("property");
    for (BackboneElement item : properties) {
      tgt.addChild("property", item);
    }
    tgt.clear("referenceInformation");
    if (referenceInformation != null) {
      tgt.addChild("referenceInformation", referenceInformation);
    }
    tgt.clear("molecularWeight");
    for (BackboneElement item : molecularWeights) {
      tgt.addChild("molecularWeight", item);
    }
    tgt.clear("structure");
    if (structure != null) {
      tgt.addChild("structure", structure);
    }
    tgt.clear("code");
    for (BackboneElement item : codes) {
      tgt.addChild("code", item);
    }
    tgt.clear("name");
    for (BackboneElement item : names) {
      tgt.addChild("name", item);
    }
    tgt.clear("relationship");
    for (BackboneElement item : relationships) {
      tgt.addChild("relationship", item);
    }
    tgt.clear("nucleicAcid");
    if (nucleicAcid != null) {
      tgt.addChild("nucleicAcid", nucleicAcid);
    }
    tgt.clear("polymer");
    if (polymer != null) {
      tgt.addChild("polymer", polymer);
    }
    tgt.clear("protein");
    if (protein != null) {
      tgt.addChild("protein", protein);
    }
    tgt.clear("sourceMaterial");
    if (sourceMaterial != null) {
      tgt.addChild("sourceMaterial", sourceMaterial);
    }

  }

  public String getId() {
    return id;
  }

  public SubstanceDefinitionUvEpi setId(String value) {
    this.id = value;
    return this;
  }

  public boolean hasId() {
    return id != null;
  }

  /**
   * May be used to represent additional information that is not part of the basic 
   * definition of the resource. To make the use of extensions safe and managable, 
   * there is a strict set of governance applied to the definition and use of 
   * extensions. Though any implementer can define an extension, there is a set of 
   * requirements that SHALL be met as part of the definition of the extension.
   *
   */
  public List<Extension> getExtensions() {
    if (extensions == null) { extensions = new ArrayList<>(); }
    return extensions;
  }

  public boolean hasExtensions() {
    return extensions != null && !extensions.isEmpty();
  }

  public Extension addExtension() {
    Extension theThing = new Extension();
    getExtensions().add(theThing);
    return theThing;
  }

  public boolean hasExtension(Extension item) {
    return hasExtensions() && extensions.contains(item);
  }

  public void removeExtension(Extension item) {
    if (hasExtension(item)) {
      extensions.remove(item);
    }
  }


  /**
   * May be used to represent additional information that is not part of the basic 
   * definition of the resource and that modifies the understanding of the element 
   * that contains it and/or the understanding of the containing element's 
   * descendants. Usually modifier elements provide negation or qualification. To 
   * make the use of extensions safe and managable, there is a strict set of 
   * governance applied to the definition and use of extensions. Though any 
   * implementer is allowed to define an extension, there is a set of requirements 
   * that SHALL be met as part of the definition of the extension. Applications 
   * processing a resource are required to check for modifier extensions.
   *
   * 
   *
   * Modifier extensions SHALL NOT change the meaning of any elements on Resource or 
   * DomainResource (including cannot change the meaning of modifierExtension 
   * itself).
   *
   */
  public List<Extension> getModifierExtensions() {
    if (modifierExtensions == null) { modifierExtensions = new ArrayList<>(); }
    return modifierExtensions;
  }

  public boolean hasModifierExtensions() {
    return modifierExtensions != null && !modifierExtensions.isEmpty();
  }

  public Extension addModifierExtension() {
    Extension theThing = new Extension();
    getModifierExtensions().add(theThing);
    return theThing;
  }

  public boolean hasModifierExtension(Extension item) {
    return hasModifierExtensions() && modifierExtensions.contains(item);
  }

  public void removeModifierExtension(Extension item) {
    if (hasModifierExtension(item)) {
      modifierExtensions.remove(item);
    }
  }


  /**
   * Identifier by which this substance is known.
   *
   */
  public List<Identifier> getIdentifiers() {
    if (identifiers == null) { identifiers = new ArrayList<>(); }
    return identifiers;
  }

  public boolean hasIdentifiers() {
    return identifiers != null && !identifiers.isEmpty();
  }

  public Identifier addIdentifier() {
    Identifier theThing = new Identifier();
    getIdentifiers().add(theThing);
    return theThing;
  }

  public boolean hasIdentifier(Identifier item) {
    return hasIdentifiers() && identifiers.contains(item);
  }

  public void removeIdentifier(Identifier item) {
    if (hasIdentifier(item)) {
      identifiers.remove(item);
    }
  }


  /**
   * Supporting literature.
   *
   */
  public List<Reference> getInformationSources() {
    if (informationSources == null) { informationSources = new ArrayList<>(); }
    return informationSources;
  }

  public boolean hasInformationSources() {
    return informationSources != null && !informationSources.isEmpty();
  }

  public Reference addInformationSource() {
    Reference theThing = new Reference();
    getInformationSources().add(theThing);
    return theThing;
  }

  public boolean hasInformationSource(Reference item) {
    return hasInformationSources() && informationSources.contains(item);
  }

  public void removeInformationSource(Reference item) {
    if (hasInformationSource(item)) {
      informationSources.remove(item);
    }
  }


  /**
   * Textual comment about the substance's catalogue or registry record.
   *
   */
  public List<Annotation> getNotes() {
    if (notes == null) { notes = new ArrayList<>(); }
    return notes;
  }

  public boolean hasNotes() {
    return notes != null && !notes.isEmpty();
  }

  public Annotation addNote() {
    Annotation theThing = new Annotation();
    getNotes().add(theThing);
    return theThing;
  }

  public boolean hasNote(Annotation item) {
    return hasNotes() && notes.contains(item);
  }

  public void removeNote(Annotation item) {
    if (hasNote(item)) {
      notes.remove(item);
    }
  }


  /**
   * The entity that creates, makes, produces or fabricates the substance. This is a 
   * set of potential manufacturers but is not necessarily comprehensive.
   *
   */
  public List<Reference> getManufacturers() {
    if (manufacturers == null) { manufacturers = new ArrayList<>(); }
    return manufacturers;
  }

  public boolean hasManufacturers() {
    return manufacturers != null && !manufacturers.isEmpty();
  }

  public Reference addManufacturer() {
    Reference theThing = new Reference();
    getManufacturers().add(theThing);
    return theThing;
  }

  public boolean hasManufacturer(Reference item) {
    return hasManufacturers() && manufacturers.contains(item);
  }

  public void removeManufacturer(Reference item) {
    if (hasManufacturer(item)) {
      manufacturers.remove(item);
    }
  }


  /**
   * An entity that is the source for the substance. It may be different from the 
   * manufacturer. Supplier is synonymous to a distributor.
   *
   */
  public List<Reference> getSuppliers() {
    if (suppliers == null) { suppliers = new ArrayList<>(); }
    return suppliers;
  }

  public boolean hasSuppliers() {
    return suppliers != null && !suppliers.isEmpty();
  }

  public Reference addSupplier() {
    Reference theThing = new Reference();
    getSuppliers().add(theThing);
    return theThing;
  }

  public boolean hasSupplier(Reference item) {
    return hasSuppliers() && suppliers.contains(item);
  }

  public void removeSupplier(Reference item) {
    if (hasSupplier(item)) {
      suppliers.remove(item);
    }
  }


  /**
   * Moiety, for structural modifications.
   *
   */
  public List<BackboneElement> getMoieties() {
    if (moieties == null) { moieties = new ArrayList<>(); }
    return moieties;
  }

  public boolean hasMoieties() {
    return moieties != null && !moieties.isEmpty();
  }

  public boolean hasMoiety(BackboneElement item) {
    return hasMoieties() && moieties.contains(item);
  }

  public void removeMoiety(BackboneElement item) {
    if (hasMoiety(item)) {
      moieties.remove(item);
    }
  }


  /**
   * General specifications for this substance.
   *
   */
  public List<BackboneElement> getCharacterizations() {
    if (characterizations == null) { characterizations = new ArrayList<>(); }
    return characterizations;
  }

  public boolean hasCharacterizations() {
    return characterizations != null && !characterizations.isEmpty();
  }

  public boolean hasCharacterization(BackboneElement item) {
    return hasCharacterizations() && characterizations.contains(item);
  }

  public void removeCharacterization(BackboneElement item) {
    if (hasCharacterization(item)) {
      characterizations.remove(item);
    }
  }


  /**
   * General specifications for this substance.
   *
   */
  public List<BackboneElement> getProperties() {
    if (properties == null) { properties = new ArrayList<>(); }
    return properties;
  }

  public boolean hasProperties() {
    return properties != null && !properties.isEmpty();
  }

  public boolean hasProperty(BackboneElement item) {
    return hasProperties() && properties.contains(item);
  }

  public void removeProperty(BackboneElement item) {
    if (hasProperty(item)) {
      properties.remove(item);
    }
  }


  /**
   * General information detailing this substance.
   *
   */
  public Reference getReferenceInformation() {
    if (referenceInformation == null) { referenceInformation = new Reference(); }
    return referenceInformation;
  }

  public SubstanceDefinitionUvEpi setReferenceInformation(Reference value) {
    this.referenceInformation = value;
    return this;
  }
  public boolean hasReferenceInformation() {
    return referenceInformation != null;
  }

  /**
   * The average mass of a molecule of a compound compared to 1/12 the mass of carbon 
   * 12 and calculated as the sum of the atomic weights of the constituent atoms.
   *
   */
  public List<BackboneElement> getMolecularWeights() {
    if (molecularWeights == null) { molecularWeights = new ArrayList<>(); }
    return molecularWeights;
  }

  public boolean hasMolecularWeights() {
    return molecularWeights != null && !molecularWeights.isEmpty();
  }

  public boolean hasMolecularWeight(BackboneElement item) {
    return hasMolecularWeights() && molecularWeights.contains(item);
  }

  public void removeMolecularWeight(BackboneElement item) {
    if (hasMolecularWeight(item)) {
      molecularWeights.remove(item);
    }
  }


  /**
   * Structural information.
   *
   */
  public @Nullable BackboneElement getStructure() { // BackboneElement is abstract 
    return structure;
  }

  public SubstanceDefinitionUvEpi setStructure(BackboneElement value) {
    this.structure = value;
    return this;
  }
  public boolean hasStructure() {
    return structure != null;
  }

  /**
   * Codes associated with the substance.
   *
   */
  public List<BackboneElement> getCodes() {
    if (codes == null) { codes = new ArrayList<>(); }
    return codes;
  }

  public boolean hasCodes() {
    return codes != null && !codes.isEmpty();
  }

  public boolean hasCode(BackboneElement item) {
    return hasCodes() && codes.contains(item);
  }

  public void removeCode(BackboneElement item) {
    if (hasCode(item)) {
      codes.remove(item);
    }
  }


  /**
   * Names applicable to this substance.
   *
   */
  public List<BackboneElement> getNames() {
    if (names == null) { names = new ArrayList<>(); }
    return names;
  }

  public boolean hasNames() {
    return names != null && !names.isEmpty();
  }

  public boolean hasName(BackboneElement item) {
    return hasNames() && names.contains(item);
  }

  public void removeName(BackboneElement item) {
    if (hasName(item)) {
      names.remove(item);
    }
  }


  /**
   * A link between this substance and another, with details of the relationship.
   *
   */
  public List<BackboneElement> getRelationships() {
    if (relationships == null) { relationships = new ArrayList<>(); }
    return relationships;
  }

  public boolean hasRelationships() {
    return relationships != null && !relationships.isEmpty();
  }

  public boolean hasRelationship(BackboneElement item) {
    return hasRelationships() && relationships.contains(item);
  }

  public void removeRelationship(BackboneElement item) {
    if (hasRelationship(item)) {
      relationships.remove(item);
    }
  }


  /**
   * Data items specific to nucleic acids.
   *
   */
  public Reference getNucleicAcid() {
    if (nucleicAcid == null) { nucleicAcid = new Reference(); }
    return nucleicAcid;
  }

  public SubstanceDefinitionUvEpi setNucleicAcid(Reference value) {
    this.nucleicAcid = value;
    return this;
  }
  public boolean hasNucleicAcid() {
    return nucleicAcid != null;
  }

  /**
   * Data items specific to polymers.
   *
   */
  public Reference getPolymer() {
    if (polymer == null) { polymer = new Reference(); }
    return polymer;
  }

  public SubstanceDefinitionUvEpi setPolymer(Reference value) {
    this.polymer = value;
    return this;
  }
  public boolean hasPolymer() {
    return polymer != null;
  }

  /**
   * Data items specific to proteins.
   *
   */
  public Reference getProtein() {
    if (protein == null) { protein = new Reference(); }
    return protein;
  }

  public SubstanceDefinitionUvEpi setProtein(Reference value) {
    this.protein = value;
    return this;
  }
  public boolean hasProtein() {
    return protein != null;
  }

  /**
   * Material or taxonomic/anatomical source for the substance.
   *
   */
  public @Nullable BackboneElement getSourceMaterial() { // BackboneElement is abstract 
    return sourceMaterial;
  }

  public SubstanceDefinitionUvEpi setSourceMaterial(BackboneElement value) {
    this.sourceMaterial = value;
    return this;
  }
  public boolean hasSourceMaterial() {
    return sourceMaterial != null;
  }



  public void clear() {
    id = null;
    extensions.clear();
    modifierExtensions.clear();
    identifiers.clear();
    informationSources.clear();
    notes.clear();
    manufacturers.clear();
    suppliers.clear();
    moieties.clear();
    characterizations.clear();
    properties.clear();
    referenceInformation = null;
    molecularWeights.clear();
    structure = null;
    codes.clear();
    names.clear();
    relationships.clear();
    nucleicAcid = null;
    polymer = null;
    protein = null;
    sourceMaterial = null;

  }

}
